package com.openatc.autoprogram;

import com.openatc.autoprogram.thread.AutoSendMsgThread;
import com.openatc.autoprogram.thread.AutoSendStatusPattern;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class AutoprogramApplication implements CommandLineRunner {
    @Value("${openatc.url}")
    private String url;

    @Value("${openatc.port}")
    private int port;

    @Value("${dev.agentid}")
    private String agentid;

    @Value("${thread.count}")
    private Integer devCount;





    public static void main(String[] args) {
        SpringApplication.run(AutoprogramApplication.class, args);

    }

    @Override
    public void run(String... args) throws Exception {
        for (int i = 1; i <= devCount; i++) {
            String agentid = "auto-" + i;
            new AutoSendMsgThread(url,port,agentid).start();
            new AutoSendStatusPattern(url,port,agentid).start();
        }

    }
}
